package com.yysoft.dubbo.consumer.listener;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.springframework.jms.listener.SessionAwareMessageListener;

public class MyQueueMessageListener implements SessionAwareMessageListener<Message> {

	@Override
	public void onMessage(Message message, Session session) throws JMSException {
		if (message instanceof TextMessage) {
			System.out.println("队列消费者消费消息：" + ((TextMessage) message).getText());
			//响应，对应“发送且接收”模式
			if (message.getJMSReplyTo() != null) {
				MessageProducer messageProducer = session.createProducer(message.getJMSReplyTo());
				messageProducer.send(session.createTextMessage("你好3！"));
			}
		}
	}

}
